﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;


namespace DAL.BusinessDeal
{
    public  class StSpProcessVoyageDAL
    {
        private const string selectProcessVoytageDAL = null;

        /// <summary>
        /// Get DataTable
        /// </summary>
        /// <param name="textWhere">conditon</param>
        /// <param name="orderText">sort</param>
        /// <returns></returns>
        public DataTable GetTable()
        {
            return GetDataTable(selectProcessVoytageDAL);
        }

        /// <summary>
        /// Get DataTable
        /// </summary>
        /// <param name="sql">SQL statement</param>
        /// <returns></returns>
        public DataTable GetDataTable(string sql)
        {
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(sql);
            DataTable dt = db.ExecuteDataTable(dbCommand);
            if (dt != null)
            {
                dt.TableName = "SP_Process_Voyage";
            }
            return dt;
        }

        /// <summary>
        /// 新增 修改 数据
        /// </summary>
        /// <param name="P_Operation_Code"></param>
        /// <param name="P_VOY_ID"></param>
        /// <param name="P_User_ID"></param>
        /// <param name="P_VOY_IEFG"></param>
        /// <param name="P_VOY_SLN_ID"></param>
        /// <param name="P_SCD_ID"></param>
        /// <param name="P_VOY_FLT_ID"></param>
        /// <param name="P_VOY_VOYAGE"></param>
        /// <param name="P_VOY_INTRADE"></param>
        /// <returns></returns>
        public string InsertUpdateProcessVoyage(int P_Operation_Code, int P_VOY_ID, int P_User_ID,
            string P_VOY_IEFG, int P_VOY_SLN_ID, int P_SCD_ID, int P_VOY_FLT_ID, string P_VOY_VOYAGE,
            string P_VOY_INTRADE)
        {

            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("web_sp_process_voyage");
            db.AddInParameter(dbCommand, "P_Operation_Code", DbType.Int32, P_Operation_Code);
            db.AddInParameter(dbCommand, "P_VOY_ID", DbType.Int32, P_VOY_ID);
            db.AddInParameter(dbCommand, "P_User_ID", DbType.Int32, P_User_ID);
            db.AddInParameter(dbCommand, "P_VOY_IEFG", DbType.String, P_VOY_IEFG);
            db.AddInParameter(dbCommand, "P_VOY_SLN_ID", DbType.Int32, P_VOY_SLN_ID);
            db.AddInParameter(dbCommand, "P_SCD_ID", DbType.Int32, P_SCD_ID);
            db.AddInParameter(dbCommand, "P_VOY_FLT_ID", DbType.Int32, P_VOY_FLT_ID);
            db.AddInParameter(dbCommand, "P_VOY_VOYAGE", DbType.String, P_VOY_VOYAGE);
            db.AddInParameter(dbCommand, "P_VOY_INTRADE", DbType.String, P_VOY_INTRADE);
            db.AddOutParameter(dbCommand, "results", DbType.String, 1000);
            dbCommand.Parameters["results"].Direction = ParameterDirection.Output;
            db.ExecuteNonQuery(dbCommand);
            return dbCommand.Parameters["results"].Value.ToString();
        }
    }//end class
}
